<?php
namespace Home\Controller;
use Think\Controller;
use Think\model;
class FormController extends Controller{
	public function add(){
		$this->display();
	}
    public function form(){
        
    	$db     = M('Form');
        $data['title'] = I('post.title');
        $data['content'] = I('post.content');
        $data['careate_time'] = time();
        $this->display();
    }
    public function insert(){
        $Form   =   D('Form');
        $code = I('post.vcode');
        $verify = new \Think\Verify();
        $ret =  $verify->check($code);
        if (!$ret){
            $this->error("验证码错误");
        }
        if($Form->create()) {
            $result =   $Form->add();
            if($result) {
                $this->success('数据添加成功！');
            }else{
                $this->error('数据添加错误！');
            }
        }else{
            $this->error($Form->getError());
        }
    }
 public function edit($id=0){
    $Form   =   M('Form');
    $this->assign('vo',$Form->find($id));
    $this->display();
 }
 public function update(){
    $Form   =   D('Form');
    if($Form->create()) {
        $result =   $Form->save();
        if($result) {
            $this->success('操作成功！');
        }else{
            $this->error('写入错误！');
        }
    }else{
        $this->error($Form->getError());
    }
 }
         public function vcode(){
            $config =    array(
            'fontSize'    =>    30,    // 验证码字体大小
            'length'      =>    5,     // 验证码位数
            'useNoise'    =>    true, // 关闭验证码杂点


            
        );
        $Verify =     new \Think\Verify($config);
        //$Verify->useZh = true; 
        $Verify->useImgBg = true;
        $Verify->fontttf = '3.ttf';
        //$Verify->useZh = true;
        
        $Verify->entry();
         }


}